﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent">
    <ControlTemplate x:Key="BackstageTabItemControlTemplate"
                     TargetType="{x:Type Fluent:BackstageTabItem}">
        <Grid Background="#00000000">
            <Border x:Name="hoverBorder"
                    Margin="0,0,1,0"
                    Background="{Binding Background,
                                         RelativeSource={RelativeSource FindAncestor,
                                                                        AncestorType={x:Type Fluent:BackstageTabControl}}}"
                    BorderBrush="{x:Null}"
                    BorderThickness="0"
                    Visibility="Collapsed">
                <Border Background="#BFFFFFFF"
                        BorderBrush="#4C000000"
                        BorderThickness="0,1" />
            </Border>
            <Border x:Name="selectedBorder"
                    Margin="0"
                    Background="{Binding Background,
                                         RelativeSource={RelativeSource FindAncestor,
                                                                        AncestorType={x:Type Fluent:BackstageTabControl}}}"
                    BorderBrush="#FF000463"
                    BorderThickness="0"
                    Visibility="Collapsed">
                <Grid Width="Auto"
                      Margin="0"
                      HorizontalAlignment="Stretch">
                    <Border BorderBrush="#7F000000"
                            BorderThickness="0,1">
                        <Border.Background>
                            <RadialGradientBrush Center="0.5,0.972" GradientOrigin="0.5,0.972" RadiusX="0.662" RadiusY="1.193">
                                <RadialGradientBrush.RelativeTransform>
                                    <TransformGroup>
                                        <ScaleTransform CenterX="0.5"
                                                        CenterY="0.972"
                                                        ScaleX="1"
                                                        ScaleY="1" />
                                        <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.972" />
                                        <RotateTransform Angle="-0.659" CenterX="0.5" CenterY="0.972" />
                                        <TranslateTransform />
                                    </TransformGroup>
                                </RadialGradientBrush.RelativeTransform>
                                <GradientStop Offset="0" Color="#A5FFFFFF" />
                                <GradientStop Offset="1" />
                            </RadialGradientBrush>
                        </Border.Background>
                    </Border>
                    <Path Width="8"
                          Height="15"
                          Margin="0,0,-1,0"
                          HorizontalAlignment="Right"
                          VerticalAlignment="Center"
                          Data="M1,0L0,1 1,2z"
                          Fill="{DynamicResource BackstageBackgroundBrush}"
                          Stretch="Fill"
                          Stroke="{x:Null}"
                          StrokeThickness="0" />
                </Grid>
            </Border>
            <ContentControl x:Name="PART_Header"
                            Margin="20,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Content="{TemplateBinding Header}">
                <ContentControl.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="TextWrapping"
                                Value="NoWrap" />
                        <Setter Property="TextTrimming"
                                Value="CharacterEllipsis" />
                    </Style>
                </ContentControl.Resources>
            </ContentControl>
        </Grid>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                    <Condition Property="IsEnabled"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter TargetName="hoverBorder"
                        Property="Visibility"
                        Value="Visible" />
            </MultiTrigger>
            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter TargetName="hoverBorder"
                        Property="Visibility"
                        Value="Hidden" />
                <Setter TargetName="PART_Header"
                        Property="Opacity"
                        Value="0.5" />
            </Trigger>
            <Trigger Property="Selector.IsSelected"
                     Value="True">
                <Setter TargetName="selectedBorder"
                        Property="Visibility"
                        Value="Visible" />
                <Setter TargetName="PART_Header"
                        Property="Foreground"
                        Value="White" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>


    <Style x:Key="BackstageTabItemStyle"
           TargetType="{x:Type Fluent:BackstageTabItem}">
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFontFamily}" />
        <Setter Property="Foreground"
                Value="{DynamicResource BackstageFontBrush}" />
        <Setter Property="Template"
                Value="{StaticResource BackstageTabItemControlTemplate}" />
        <Setter Property="FocusVisualStyle"
                Value="{DynamicResource ControlStyleEmptyFocus}" />
        <Setter Property="Height"
                Value="37" />
        <Setter Property="Background"
                Value="{Binding Background,
                                RelativeSource={RelativeSource FindAncestor,
                                                               AncestorType={x:Type Fluent:BackstageTabControl}}}" />
        <Setter Property="Margin"
                Value="0,1" />
    </Style>
</ResourceDictionary>